<template>
    <uxt-page :title="title">
        <uxt-bar-group title="设置">
            <uxt-single-selector-bar
                title="类型"
                desc="type"
                v-model="type"
                :options="types"
            ></uxt-single-selector-bar>
            <uxt-bar title="时长" desc="duration">
                <template slot="right">
                    <uxt-input
                        classes="solid radius margin-xs"
                        :styles="{ width: '100rpx' }"
                        v-model="duration"
                    ></uxt-input>
                    ms
                </template>
            </uxt-bar>
            <uxt-bar title="提示内容" desc="message">
                <template slot="right">
                    <uxt-input
                        classes="solid radius margin-xs"
                        :styles="{ width: '400rpx' }"
                        v-model="message"
                    ></uxt-input>
                </template>
            </uxt-bar>
            <uxt-bar title="图标" desc="icon">
                <template slot="right">
                    <uxt-input
                        classes="solid radius margin-xs"
                        :styles="{ width: '200rpx' }"
                        v-model="icon"
                    ></uxt-input>
                </template>
            </uxt-bar>
            <uxt-bar title="不可点击页面其它地方">
                <template slot="right">
                    <uxt-switch v-model="noClick" radius size="sm"></uxt-switch>
                </template>
            </uxt-bar>
        </uxt-bar-group>
        <uxt-bar-group title="展示">
            <view class="padding bg-white text-center">
                <view class="padding bg-theme text-center round" @click="handleClick">
                    显示提示
                </view>
            </view>
        </uxt-bar-group>
    </uxt-page>
</template>

<script>
import uxtBarGroup from '@xtcoder/uxt/components/uxt-bar-group.vue'
import uxtBar from '@xtcoder/uxt/components/uxt-bar.vue'
import uxtInput from '@xtcoder/uxt/components/uxt-input.vue'
import uxtSingleSelectorBar from '@xtcoder/uxt/components/uxt-single-selector-bar.vue'
import uxtSwitch from '@xtcoder/uxt/components/uxt-switch.vue'

export default {
    components: {
        uxtBarGroup,
        uxtBar,
        uxtInput,
        uxtSingleSelectorBar,
        uxtSwitch
    },
    data() {
        return {
            title: '轻提示',
            message: '轻提示',
            duration: 3000,
            icon: '',
            types: ['默认', '加载提示', '成功提示', '失败提示'],
            typeValues: ['df', 'loading', 'success', 'fail'],
            type: 0,
            noClick: false
        }
    },
    methods: {
        handleClick() {
            this.uxtToast({
                message: this.message,
                duration: Number(this.duration),
                icon: this.icon,
                type: this.typeValues[this.type],
                noClick: this.noClick
            }).show()
            if (this.type === 1) {
                setTimeout(() => {
                    this.uxtToast().hide()
                }, 5000)
            }
        }
    }
}
</script>

<style lang="scss" scoped></style>
